namespace CISLib
{
    using System;
    using System.Data;
    using System.Text;

    public class ManageResourceCount
    {
        public static DataSet GetCount(string tableName)
        {
            string strSQL = "select 'All' as NoRegionName,count(*) as ResourceCount from " + tableName + " ";
            DBAccess MyDB = new DBAccess();
            MyDB.DBOpen();
            MyDB.DBSetSelect(strSQL);
            return MyDB.DBReturnDataSet();
        }

        public static DataSet GetCount(string tableName, string ColumnName)
        {
            string strSQL = "";
            StringBuilder sb = new StringBuilder();
            sb.Append("select Tb_region.RegionName,                                                                           ");
            sb.Append("\t\tcount(Tb_region.RegionName) as ResourceCount                                                      ");
            sb.Append("from  " + tableName + "  left outer join Tb_region on " + tableName + "." + ColumnName + " = Tb_region.regionId    ");
            sb.Append("group by Tb_region.RegionName   ");
            strSQL = sb.ToString();
            DBAccess MyDB = new DBAccess();
            MyDB.DBOpen();
            MyDB.DBSetSelect(strSQL);
            return MyDB.DBReturnDataSet();
        }
    }
}

